#include <cstdio>

int s[ 10000002 ], n, m;

int find( int root )
{
    if ( s[ root ] == -1 )
        return root;
    return s[ root ] = find( s[ root ] );
}

void unionSet( int root1, int root2 )
{
    root1 = find( root1 );
    root2 = find( root2 );
    if ( root1 != root2 )
        s[ root1 ] = root2;
}

void work( )
{
    int i, l, r, cnt = 0, p = 1;
    __int64 ret = 1;
    for ( i = 0; i <= 10000001; i++ ) s[ i ] = -1;
    for ( i = 0; i < m; i++ )
    {
        scanf("%d%d", &l, &r);
        if ( find( l ) != find( r + 1 ) )
        {
            cnt++;
            unionSet( l, r + 1 );
        }
    }
    n -= cnt;
    while ( p <= n ) p <<= 1;
    p >>= 1;
    while ( p )
    {
        ret = ret * ret % 1000000007;
        if ( p & n ) ret = ret * 26 % 1000000007;
        p >>= 1;
    }
    printf("%I64d\n", ret);
}

int main( )
{
    while ( scanf("%d%d" ,&n, &m) != EOF )
    {
        work( );
    }
    return 0;
}
